package com.jumper.study.common.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import io.netty.util.internal.ThreadLocalRandom;

/**
 * 生成订单号
 */
public final class OrderNoUtil {
    //设计量小，直接使用日期时间+随机数生成
    public static synchronized String generate() {
        LocalDateTime time = LocalDateTime.now();
        String no = time.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));

        ThreadLocalRandom random = ThreadLocalRandom.current();

        return no + random.nextInt(1000);
    }
}
